package com.test.app;

import android.os.Bundle;
import android.util.Base64;
import android.util.Log;
import android.view.View;
import android.widget.LinearLayout;

import androidx.appcompat.app.AppCompatActivity;

import com.android.test.dfsa.sdcf.R;
import com.car.out.sdk.CarSDK;

import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;

public class GameActivity extends AppCompatActivity {

    private LinearLayout root_ll;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_game);

        CarSDK.aCarInit(this);
        Log.e("CaOut","GameActivity onCreate");

        root_ll=findViewById(R.id.root_ll);
        root_ll.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                CarSDK.aCarPlayAd("");
            }
        });

        CarSDK.aCarInterInit();
//        Log.e("CaOut", TapAesUtils.encrypt("K4zyTPLU1iQJJfNf2Tl9ZrwHS36A_E7byTF4fX_13rwXZOU1W487UIR10-rxp3xA4iPmZuWCiKrUs8TuBkcOo3", CarConstant.KEY_FLAG));
//        Log.e("CaOut", TapAesUtils.decrypt(CarConstant.MAX_KEY, CarConstant.KEY_FLAG));
    }


    public static String generateAESKey() {
        try {
            KeyGenerator keyGen = KeyGenerator.getInstance("AES");
            keyGen.init(256); // 选择密钥长度：128、192 或 256
            SecretKey secretKey = keyGen.generateKey();
            return Base64.encodeToString(secretKey.getEncoded(), Base64.DEFAULT);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}